package com.dragon.modules.yuegou.service.impl.member;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dragon.modules.yuegou.entity.member.SetEntity;
import com.dragon.modules.yuegou.mapper.member.SetMapper;
import com.dragon.modules.yuegou.model.member.Set;
import com.dragon.modules.yuegou.query.member.SetQuery;
import com.dragon.modules.yuegou.service.member.SetService;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 会员隐私设置信息表 0-是 1-否 服务实现
 *
 * @author pbuilder generated
 * @date 2019-03-19 08:59:40
 * @version 2.0
 */
@Service("memSetService")
public class SetServiceImpl extends ServiceImpl<SetMapper, SetEntity> implements SetService {

	@Override
	public Set getMemSet(String memberId) {
		//获取当前用户信息
		SetQuery setQuery = new SetQuery();
		setQuery.setMemberId(memberId);
		SetEntity set = getOne(setQuery.toQueryWrapper());
		if (Objects.isNull(set)) {
			set = new SetEntity();
			set.setMemberId(memberId);
			set.setIsReceiveAllMsg(true);
			set.setIsReceiveFollowMsg(true);
			save(set);
		}
		return new Set(set);
	}

	@Override
	public void modifyMemSet(Set set) {
		baseMapper.updateById(set);
	}

}